<#include "/common/layout_dl.html">
<@header>
</@header>
<@body>
 <form  id="roomEditForm" class="form-horizontal layui-form layui-form-pane">
  <div class="box-body">
    <div class="form-group">
        <label class="col-sm-2 control-label">房间号:</label>
        <input value="${roomInfo.roomName}"   id="roomName" name="roomName" readonly="readonly">
    </div>
    <div class="form-group">
          <label class="col-sm-2 control-label">房型:</label>
        <div class="col-sm-3">
            <select  id="roomType" name="roomType" >
                <option value="10" ${(roomInfo.roomType =="10")?string('selected="selected"','')}>单间</option>
                <option value="11" ${(roomInfo.roomType =="11")?string('selected="selected"','')}">一室一厅</option>
                <option value="21" ${(roomInfo.roomType =="21")?string('selected="selected"','')}">两室一厅</option>
                <option value="31" ${(roomInfo.roomType =="31")?string('selected="selected"','')}">三室一厅</option>
            </select>
        </div>
    </div>
    <div class="form-group">
          <label class="col-sm-2 control-label" for="application">用途:</label>
        <input value="${roomInfo.application}"  id="application" name="application">
    </div>
      <div class="form-group">
          <label class="col-sm-2 control-label"> 房间面积(平方米):</label>
          <input value="${roomInfo.size}" id="size" name="size" data-rule="房间面积:required;integer(+);range(1-999,true)">
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">朝向:</label>
          <input value="${roomInfo.orientation}" id="orientation" name="orientation" data-rule="朝向:required;length(1~2)">
      </div>
      <div class="form-group">
          <label  class="col-sm-2 control-label">出租状态</label>
          <div class="col-sm-10">
              <label>
                  <input name="state" type="radio" class="minimal" ${(roomInfo.state ==1)?string('checked','')} value="1" data-rule="checked" lay-ignore> 已出租
              </label>
              <label>
                  <input name="state" type="radio" class="minimal" ${(roomInfo.state ==0)?string('checked','')}  value="0" lay-ignore> 未出租
              </label>
          </div>
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">配套设施:</label>
          <div class="col-sm-8">
              <textarea class="form-control" name="appendix" rows="1" placeholder="请输入描述，最多30个字符 ..." data-rule="length(0~30)">${(roomInfo.appendix)!}</textarea>
          </div>
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">家用电器:</label>
          <div class="col-sm-8">
              <textarea class="form-control" name="houseAppliances" rows="1" placeholder="请输入描述，最多30个字符 ..." data-rule="length(0~30)">${(roomInfo.houseAppliances)!}</textarea>
          </div>
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">租金:</label>
          <input value="${roomInfo.rental}" id="rental" name="rental" data-rule="租金:required">
      </div>
      <div class="form-group">
          <label  class="col-sm-2 control-label">押付模式</label>
          <div class="col-sm-10">
              <label>
                  <input name="rentPatten" type="radio"   class="minimal" ${(roomInfo.rentPatten ==1)?string('checked','')} value="1" lay-ignore> 押一付一
              </label>
              <label>
                  <input name="rentPatten" type="radio"  class="minimal" ${(roomInfo.rentPatten ==2)?string('checked','')}  value="2" lay-ignore> 押二付一
              </label>
              <label>
                  <input name="rentPatten" type="radio"  class="minimal" ${(roomInfo.rentPatten ==3)?string('checked','')}  value="3" data-rule="checked" lay-ignore> 押金自定义
              </label>
          </div>
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">押金:</label>
          <input value="${roomInfo.deposit}" id="deposit" name="deposit" data-rule="押金:required">
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">网费:</label>
          <input value="${roomInfo.netPrice}" id="netPrice" name="netPrice" data-rule="网费:required;">
      </div>
      <div class="form-group">
          <label  class="col-sm-2 control-label">电梯房</label>
          <div class="col-sm-10">
              <label>
                  <input name="hasLift" type="radio" class="minimal" ${(roomInfo.hasLift ==1)?string('checked','')} value="1" data-rule="checked" lay-ignore> 是
              </label>
              <label>
                  <input name="hasLift" type="radio" class="minimal" ${(roomInfo.hasLift ==0)?string('checked','')}  value="0" lay-ignore> 否
              </label>
          </div>
      </div>

     <div class="form-group">
      	<label  class="col-sm-2 control-label"></label>
       	<div class="col-sm-10">
       		 <button type="submit" class="btn btn-success" ><i class="fa fa-save"></i>  提 交</button>
       	</div>
     </div>
  </div><!-- /.box-body -->
</form>

</@body>
<@footer>
  <script type="text/javascript">
      $("input:radio[name='rentPatten']").on('ifChecked', function(event){
          var opt=$("input:radio[name='rentPatten']:checked").val();
          if(1 ==opt){
              //押一付一
              var rentalInput = document.getElementById("rental");
              var rental = rentalInput.value;
              var deposit = rental;
              document.getElementById('deposit').value =deposit;
              document.getElementById('deposit').setAttribute("readonly",true);
          }else if(2==opt){
              //押二付一
              var rentalInput = document.getElementById("rental");
              var rental = rentalInput.value;
              var deposit = rental;
              document.getElementById('deposit').value =2*deposit;
              document.getElementById('deposit').setAttribute("readonly",true);
          }else{
              //自定义
              document.getElementById('deposit').removeAttribute("readonly")
          }
      });

      //接收表单验证通过的事件
      $('#roomEditForm').bind('valid.form', function(){
          $.ajax({
              url: '/hm/roomManager/doEdit',
              type: 'POST',
              dataType:'json',
              data: $(this).serialize(),
              success: function(result){
                  layer.msg(result.msg, {time: 2000},function(){
                      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                      parent.layer.close(index);
                  });
              }
          });
      });
  </script>
</@footer>